package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.logic.activity.silkroad.SilkRoadConfig;
import com.yanqu.road.server.manger.activity.silkroad.SilkRoadMgr;

import java.util.ArrayList;

public class SilkRoadRecycleStrategy extends AbstractItemRecycleStrategy {

    @Override
    public void markNeedRecycleItem() {

        SilkRoadConfig config = SilkRoadMgr.getConfig();
        if (config != null) {
            long recycleTime = config.getActivityInfo().getEndShowTime() * 1000L + 600 * 1000;
            ActivityItemRecycleMgr.addRecycleItemData(config.getSILKROAD_ITEM_TICKET_NAVIGATION(), config.getActivityInfo().getType(), 2, recycleTime, new ArrayList<>());
            ActivityItemRecycleMgr.addRecycleItemData(config.getSILKROAD_ITEM_TICKET_SALVAGE(), config.getActivityInfo().getType(), 2, recycleTime, new ArrayList<>());
        }

    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.SilkRoad.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {

        if (data.getRecycleType() == 2) {
            UserBagItem userBagItem = getUserBagItem(userId, data.getItemId());
            if (userBagItem != null && userBagItem.getNum() > 0) {
                removeItem(userBagItem);
            }
        } else if (data.getRecycleType() == 1) {
            item2ScoreEx(userId, data);
        }
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }
}
